import { createApp } from "vue";
import DialogView from "../components/DialogView.vue";
import type { DialogParams } from "@/api/test/index.d";

export default function createDialog({ config, taskId }: { config: Partial<DialogParams>; taskId: string }) {
  const app = createApp(DialogView, {
    config,
    taskId,
    modelValue: true,
    onClose: () => {
      unmount();
    }
  });
  // 挂载弹窗组件
  const parentNode = document.createElement("div");
  document.body.appendChild(parentNode);
  // 卸载弹窗组件
  const unmount = () => {
    app.unmount();
    document.body.removeChild(parentNode);
  };
  app.mount(parentNode);
}
